package com.gopay.common.domain.ep;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.gopay.common.cipher.utils.SensitiveInfoDictionaryUtils;
import com.gopay.common.cipher.utils.SensitiveInfoUtils;
import com.gopay.common.constants.ep.EpBindState;
import com.gopay.common.constants.ep.EpCardType;
import com.gopay.common.domain.BaseEntity;

/**
 * 快捷支付卡绑定信息
 * 
 * @EpCardBindInfo.java
 * @author zhangjunyu
 * @2014-8-29 上午11:11:51 www.gopay.com.cn Inc.All rights reserved.
 */
@Entity
//@Table(name = "EP_CARD_BIND_INFO")
@Table(name = "EP_CARD_BIND_INFO_SEC")
public class EpCardBindInfo extends BaseEntity {
    
    private static final long serialVersionUID = -6199416436301767111L;

    /**
     * 主键
     */
   private Integer sq;
    
    /**
     * 客户编号
     */
    private String custId;
    
    /**
     * 用户绑定手机号
     */
    private String bindMobile;

    /**
     * 证件类型
     */
    private String certType;

    /**
     * 证件号码
     */
    private String certNo;
    
    /**
     * 银行卡号
     */
    private String bankAcctNum;

    /**
     * 银行编号
     */
    private String bankCode;

    /**
     * 银行卡类型 0 借记卡 1 贷记卡 2 准贷记卡 3 预付费卡
     */
    private EpCardType bankAcctType;

    /**
     * 绑定状态
     */
    private EpBindState bindState;

    /**
     * 绑定时间
     */
    private Date bindTime;

    /**
     * 解绑时间
     */
    private Date unBindTime;

    /**
     * 信用卡有效期
     */
    private String creditCardExpired;

    /**
     * 银行签约协议号
     */
    private String protocalNo;

    /**
     * 银行卡户名
     */
    private String bankAcctName;

    /**
     * 银行返回证件类型
     */
    private String bankCertType;

    /**
     * 银行返回证件号码
     */
    private String bankCertNo;

    /**
     * 银行返回电子邮箱
     */
    private String bankCustEmail;

    /**
     * 银行返回手机号码
     */
    private String bankCustMobile;

    /**
     * 银行备注1
     */
    private String bankRemark1;

    /**
     * 银行备注2
     */
    private String bankRemark2;

    /**
     * 银行备注3
     */
    private String bankRemark3;

    /**
     * 银行备注4
     */
    private String bankRemark4;

    /**
     * 银行备注5
     */
    private String bankRemark5;

    /**
     * 银行备注6
     */
    private String bankRemark6;

    /**
     * 备注字段1
     */
    private String remark1;

    /**
     * 备注字段2
     */
    private String remark2;

    private Date createdTs;
    
    private Date lastUpdTs;
    /**
     *是否首选1-首选 0-不首选
     */
    private Integer firstChoice;
    
    @Id
    @SequenceGenerator(name = "EpCardBindInfoSequence", sequenceName = "EP_CARD_BIND_INFO_SEQ")
    @GeneratedValue(generator = "EpCardBindInfoSequence", strategy = GenerationType.SEQUENCE)
    @Column(name = "SQ", unique = true, nullable = false, length = 30)
    public Integer getSq() {
        return sq;
    }

    public void setSq(Integer sq) {
        this.sq = sq;
    }

    @Column(name = "CUST_ID")
    public String getCustId() {
        return custId;
    }

    public void setCustId(String custId) {
        this.custId = custId;
    }

    @Column(name = "BIND_MOBILE")
    public String getBindMobile() {
        //return bindMobile;
        /**
         * modified by zyt 2017-4-10 自动重新加密并解密返回
         */
        this.bindMobile = SensitiveInfoUtils.autoReencrypt(this.bindMobile);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.bindMobile);
    }

    public void setBindMobile(String bindMobile) {
        //this.bindMobile = bindMobile;
        /**
         * modified by zyt 2017-4-10 写操作的时候做加密
         */
        this.bindMobile = SensitiveInfoUtils.smartEncryptWithCheck(bindMobile);
    }

    @Column(name = "CERT_TYPE")
    public String getCertType() {
        return certType;
    }

    public void setCertType(String certType) {
        this.certType = certType;
    }

    @Column(name = "CERT_NO")
    public String getCertNo() {
        /**
    	 * modify by zyt，在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 * 2017-1-5
    	 */
    	this.certNo = SensitiveInfoUtils.autoReencrypt(this.certNo);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.certNo);
    }

    public void setCertNo(String certNo) {
    	/**
    	 * modified by zyt，判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 * 2017-1-5
    	 */
    	this.certNo = SensitiveInfoUtils.smartEncryptWithCheck(certNo);
    }

    @Column(name = "BANK_ACCT_NUM")
    public String getBankAcctNum() {
        /**
    	 * modify by zyt，在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 * 2017-1-5
    	 */
    	this.bankAcctNum = SensitiveInfoUtils.autoReencrypt(this.bankAcctNum);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.bankAcctNum);
    }

    public void setBankAcctNum(String bankAcctNum) {
    	/**
    	 * modified by zyt，判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 * 2017-1-5
    	 */
    	this.bankAcctNum = SensitiveInfoUtils.smartEncryptWithCheck(bankAcctNum);
    }

    @Column(name = "BANK_CODE")
    public String getBankCode() {
        return bankCode;
    }

    public void setBankCode(String bankCode) {
        this.bankCode = bankCode;
    }

    @Column(name = "BANK_ACCT_TYPE", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    public EpCardType getBankAcctType() {
        return bankAcctType;
    }

    public void setBankAcctType(EpCardType bankAcctType) {
        this.bankAcctType = bankAcctType;
    }

    @Column(name = "BIND_STATE", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    public EpBindState getBindState() {
        return bindState;
    }

    public void setBindState(EpBindState bindState) {
        this.bindState = bindState;
    }

    @Column(name = "BIND_TIME")
    public Date getBindTime() {
        return bindTime;
    }

    public void setBindTime(Date bindTime) {
        this.bindTime = bindTime;
    }

    @Column(name = "UNBIND_TIME")
    public Date getUnBindTime() {
        return unBindTime;
    }

    public void setUnBindTime(Date unBindTime) {
        this.unBindTime = unBindTime;
    }



    @Column(name = "PROTOCAL_NO")
    public String getProtocalNo() {
        return protocalNo;
    }

    public void setProtocalNo(String protocalNo) {
        this.protocalNo = protocalNo;
    }

    @Column(name = "BANK_ACCT_NAME")
    public String getBankAcctName() {
    	/**
    	 * modify by zyt，在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 * 2017-1-5
    	 */
    	this.bankAcctName = SensitiveInfoUtils.autoReencrypt(this.bankAcctName);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.bankAcctName);
    }

    public void setBankAcctName(String bankAcctName) {
    	/**
    	 * modified by zyt，判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 * 2017-1-5
    	 */
    	this.bankAcctName = SensitiveInfoUtils.smartEncryptWithCheck(bankAcctName);
    }

    @Column(name = "BANK_CERT_TYPE")
    public String getBankCertType() {
        return bankCertType;
    }

    public void setBankCertType(String bankCertType) {
        this.bankCertType = bankCertType;
    }

    @Column(name = "BANK_CERT_NO")
    public String getBankCertNo() {
        return bankCertNo;
    }

    public void setBankCertNo(String bankCertNo) {
        this.bankCertNo = bankCertNo;
    }

    @Column(name = "BANK_CUST_EMAIL")
    public String getBankCustEmail() {
        return bankCustEmail;
    }

    public void setBankCustEmail(String bankCustEmail) {
        this.bankCustEmail = bankCustEmail;
    }

    @Column(name = "BANK_CUST_MOBILE")
    public String getBankCustMobile() {
        return bankCustMobile;
    }

    public void setBankCustMobile(String bankCustMobile) {
        this.bankCustMobile = bankCustMobile;
    }

    @Column(name = "BANK_REMARK1")
    public String getBankRemark1() {
        return bankRemark1;
    }

    public void setBankRemark1(String bankRemark1) {
        this.bankRemark1 = bankRemark1;
    }

    @Column(name = "BANK_REMARK2")
    public String getBankRemark2() {
        return bankRemark2;
    }

    public void setBankRemark2(String bankRemark2) {
        this.bankRemark2 = bankRemark2;
    }

    @Column(name = "BANK_REMARK3")
    public String getBankRemark3() {
        return bankRemark3;
    }

    public void setBankRemark3(String bankRemark3) {
        this.bankRemark3 = bankRemark3;
    }

    @Column(name = "BANK_REMARK4")
    public String getBankRemark4() {
        return bankRemark4;
    }

    public void setBankRemark4(String bankRemark4) {
        this.bankRemark4 = bankRemark4;
    }

    @Column(name = "BANK_REMARK5")
    public String getBankRemark5() {
        return bankRemark5;
    }

    public void setBankRemark5(String bankRemark5) {
        this.bankRemark5 = bankRemark5;
    }

    @Column(name = "BANK_REMARK6")
    public String getBankRemark6() {
        return bankRemark6;
    }

    public void setBankRemark6(String bankRemark6) {
        this.bankRemark6 = bankRemark6;
    }

    @Column(name = "REMARK1")
    public String getRemark1() {
        return remark1;
    }

    public void setRemark1(String remark1) {
        this.remark1 = remark1;
    }

    @Column(name = "REMARK2")
    public String getRemark2() {
        return remark2;
    }

    public void setRemark2(String remark2) {
        this.remark2 = remark2;
    }

    @Column(name = "CREATED_TS")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCreatedTs() {
		return createdTs;
	}

	public void setCreatedTs(Date createdTs) {
		this.createdTs = createdTs;
	}

	@Column(name = "LAST_UPD_TS")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getLastUpdTs() {
		return lastUpdTs;
	}

	public void setLastUpdTs(Date lastUpdTs) {
		this.lastUpdTs = lastUpdTs;
	}

	@Column(name = "FIRST_CHOICE")
    public Integer getFirstChoice() {
		return firstChoice;
	}

	public void setFirstChoice(Integer firstChoice) {
		this.firstChoice = firstChoice;
	}

	@Column(name = "CREDIT_CARD_EXPIRED")
    public String getCreditCardExpired() {
        /**
    	 * modify by zyt，在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 * 2017-1-5
    	 */
    	this.creditCardExpired = SensitiveInfoUtils.autoReencrypt(this.creditCardExpired);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.creditCardExpired);
    }

    public void setCreditCardExpired(String creditCardExpired) {
    	/**
    	 * modified by zyt，判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 * 2017-1-5
    	 */
    	this.creditCardExpired = SensitiveInfoUtils.smartEncryptWithCheck(creditCardExpired);
    }
    
}
